/**
 * \file Field.h
 * \brief Header for \a Field class.
 * \ingroup Map
 */

#ifndef FIELD_H
#define FIELD_H

#include<QList>

/**
 * \enum FieldType
 * \brief All types of fields currently in the game.
 * \ingroup Map
 */

enum FieldType{
	FIELD_GRASS,
	FIELD_ROCKS,
	FIELD_HILLS,
	FIELD_BUSH,
	FIELD_FOREST,
	FIELD_WATER,
	FIELD_SWAMP
};

class Unit;

/**
 * \class Field
 * \brief Class to model a field of the game map.
 * \ingroup Map
 */

class Field{
public:
	static Field *getField(FieldType type, int r, int c);///<Should be used as constructor. \param type Type of field. \param r Row. \param c Column.
	
	virtual FieldType type()const=0;///<Returns \a FieldType of this field.
	virtual int movementCost()const=0;///<Returns movement cost associated with this field type.
	
	virtual ~Field();///<Destructor.
	
	void addNeighbour(Field *other);///<Adds a neighbour (to get a graph-like structure). \param other The neighbour to add.
	const QList<Field*> &neighbours()const{ return m_neighbours; }///<Returns this \a Field 's neighbours.
	
	Unit *occupiedBy()const{ return m_occupiedBy; }///<Returns the \a Unit occupying this \a Field, or 0 if none.
	void setOccupiedBy(Unit *unit){ m_occupiedBy = unit; }///<Mark this \a Field as occupied. \param unit The \a Unit occupying this \a Field.
	
	int row()const{ return m_row; }///<Row number.
	int col()const{ return m_col; }///<Column number.
	
	int distance(const Field *other)const;///<Calculates distance to other field, distance in # tiles. \param other The \a Field to measure distance to.
protected:
	Field(int r, int c);///<Constructor. \param r Row. \param c Column.
	
	int m_row;///<Row.
	int m_col;///<Column.
	
	QList<Field*> m_neighbours;///<Adjacent tiles.
	Unit *m_occupiedBy;///<Occupying \a Unit.
};

#endif
